Interop Forms Toolkit
How To Create an Initialize Method

Create an Intitialize Method
Parameterized constructors are not supported in Visual Basic 6.0. To work around this limitation, a common Visual Basic 6.0 design pattern was to create a method called Initialize which would be called directly after creating an object. .NET brings with it support for constructors that take parameters.  In keeping with the aforementioned design pattern, a developer may create a parameterized constructor on his .NET form and expose it to Visual Basic 6.0 as an Initialize method.  To do this, use the InteropFormInitializer attribute.

Note that the Form must always expose a default constructor, one that takes no parameters, in addition to any that are parameterized.

The code below demonstrates decorating a constructor with the InteropFormInitializer attribute.

    <InteropFormInitializer()> _
    Public Sub New(ByVal helloText As String)
        Me.New()

        lblHelloText.Text = helloText

    End Sub

To quickly define an Initialize method use the InteropInitialize snippet installed with the toolkit:  Simply type interopinit+Tab and complete the method signature.

Only certain Types may be used as parameters.  See Type Restrictions for details.